<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            border: 1px solid red;
            height: 40px;
        }
        div p{
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
<!--<div>-->
<!--    <p>123</p>-->
<!--    <p>123</p>-->
<!--</div>-->
<div class="test1">1</div>
<div class="test1">2</div>
<div class="test1">3</div>
<div class="test1">4</div>
<div class="test1">5</div>
<script>
   //  // test=1;
   //  var a='a';
   // var arr= a.split(',');
   // console.log(arr);
   var test1 = document.getElementsByClassName('test1');

    for (var i=0; i<test1.length;i++){
        test1[i].onclick = function () {
                 console.log(this);
        }
    }
</script>
</body>
</html>